package com.ler.yrmall.product.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.ler.yrmall.config.BigDecimalSerialize;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * sku
 * @author leron
 */
@Data
public class SkuVO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * skuId
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * spuId
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long spuId;

    /**
     * sku 名称
     */
    private String name;

    /**
     * sku 详情
     */
    private String skuDesc;

    /**
     * 品牌
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long brandId;

    /**
     * 分类
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long categoryId;

    /**
     * 封面
     */
    private String cover;

    /**
     * 价格
     */
    @JsonSerialize(using = BigDecimalSerialize.class)
    private BigDecimal price;

    /**
     * 状态
     */
    private Integer status;

    /**
     * 销量
     */
    private Long saleCount;

    private List<String> skuAttrs;

    private List<String> attrValues;

    /**
     * 包含的秒杀信息
     */
    private SeckillInfoVO seckillInfo;

    @Data
    public static class SeckillInfoVO implements Serializable {

        /**
         * 秒杀场次
         */
        private Long seckillId;

        /**
         * 秒杀场次名称
         */
        private String seckillName;

        private String randomCode;

        /**
         * 秒杀价格
         */
        private BigDecimal price;

        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime endTime;

    }

    /**
     * 支持快速展示的基础属性
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<String> quickShowAttr;

    private List<Attr> attrs;

    @Data
    public static class Attr {

        private Long attrId;

        private String attrName;

        private String attrValue;

    }

}
